clear all
global system "linux"

if "${system}" == "linux" {
	*global code "/"
	global code "/"
	global s "/"
}

run "${code}${s}_set-path.do"


**** 3. Prepayment
cd "${code}/tba_elig"
local flist1: dir "${Estimates}" files "harp-forcl*.gph"
local flist2: dir "${Estimates}" files "harp-pp*.gph"
local flist3: dir "${Estimates}" files "harp-forcl*.ster"
local flist4: dir "${Estimates}" files "harp-pp*.ster"
foreach f in `flist1' `flist2' `flist3' `flist4' {
	cap erase "${Estimates}/`f'"
}
local flist: dir "${log}" files "*"
foreach f of local flist {
	cap erase "${log}/`f'"
}

local cmd "sbatch -export=HOME,PATH,SHELL -a 1-16 HARP-checks-prepaid.sh" 
di "`cmd'"

local JobIdFile "${log}/job-id.csv"  
log using `JobIdFile', name("jobid") text replace
shell `cmd'
log close _all

do _sbatch-job "`JobIdFile'"


// combine figures
foreach Sample in 2 {
	foreach Var in forcl pp {
		local `Var'_list ""
		foreach n of numlist 24(12)60 {
			local `Var'_list "``Var'_list' ${Estimates}/harp-`Var'`n'-Sample`Sample'.gph"
		}
		
		graph combine ``Var'_list'  
		graph export "${figure}/harp-`Var'-Sample`Sample'.pdf", replace
	}
}
                            
// Tables for prepayment and loan characteristicredit_score
qui do _create-tables-prepaid-loanchar
